/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-17 14:00:29
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_edu_trainning_plan")
@SQLDelete(sql="update wwyt_edu_trainning_plan set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql="update wwyt_edu_trainning_plan set DELETE_FLAG = '1' where id= ?")
@Where(clause="DELETE_FLAG = '0'")
@Data
@Proxy(lazy = false)
@TableName("wwyt_edu_trainning_plan")
public class EduTrainningPlan implements java.io.Serializable{

    //columns START
     @Id
    @GeneratedValue(strategy = IDENTITY)

    //ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    //编号
    @Column(name = "CODE", length = 10, nullable = false)
    private String code;

    //名称
    @Column(name = "NAME", length = 100, nullable = false)
    private String name;

    //分类ID
    @Column(name = "TYPE_ID")
    private Long typeId;

    //编制部门ID
    @Column(name = "MAKE_DEPART_ID")
    private Long makeDepartId;

    //编制人名称
    @Column(name = "CREATE_USER_NAME", length = 12)
    private String createUserName;

    //实施日期
    @Column(name = "IMPLEMENT_TIME")
    private java.util.Date implementTime;

    //完成日期
    @Column(name = "FINISH_TIME")
    private java.util.Date finishTime;

    //培训部门ID
    @Column(name = "TRAINNING_DEPART_ID")
    private Long trainningDepartId;

    /**
     *新增字段，部门id的集合，以json字符串形式存储在数据库
     */
    @Column(name = "DEPART_IDS")
    private String departIds;

    //培训讲师ID
    @Column(name = "TRAINNING_TEACHER_ID")
    private Long trainningTeacherId;

    //计划年度
    @Column(name = "PLAN_YEAR")
    private Short planYear;

    //培训内容
    @Column(name = "CONTENT", length = 2000)
    private String content;

    //状态
    @Column(name = "STATE")
    private Integer state;

    //创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    //创建时间
   // @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    //更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    //更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;

    //删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;

    //组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    //租户
    @Column(name = "TENENT_ID")
    private Long tenentId;
    //columns END

    @Column(name = "my_train_status")
    private String myTrainStatus;

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getId())
            .toHashCode();
    }

    public boolean equals(Object obj) {
        if(obj instanceof EduTrainningPlan == false) return false;
        if(this == obj) return true;
        EduTrainningPlan other = (EduTrainningPlan)obj;
        return new EqualsBuilder()
            .append(getId(),other.getId())
            .isEquals();
    }
}

